<?php
require_once 'Zend/Db/Table/Abstract.php';
class SemesterModel extends Zend_Db_Table_Abstract
{
	protected $_name = 'semester';
	protected $_id = 'id';
	public function semester(){
		$db = Zend_Registry::get('connectDB');
		$mySql = $db->select()
					->from('semester')
					->order('id DESC');
		$list = $db->fetchAll($mySql);
		return $list;
	}
   public function id_semester($id){
		$db = Zend_Registry::get('connectDB');
		$mySql = $db->select()
					->from('semester')
					->where("id =?",$id);
		$list = $db->fetchAll($mySql);
		return $list;
	}

	public function getSemesterByTimeCurrent(){
		$date = date("Y-m-d H:i:s");
		$db = Zend_Registry::get('connectDB');
		$mySql = $db->select()
					->from('semester')
					->where("time_start <=?",$date)
					->where("time_end >=?",$date);
		$list = $db->fetchAll($mySql);
		return $list[0]["id"];
	}
	
	public function get_email_semester($email){
		$db = Zend_Registry::get('connectDB');
		$mySql = $db->select()
					->from('semester')
					->where("email =?",$email);
		$list = $db->fetchAll($mySql);
		return $list;
	}
	
	public function getsemesterList(){
		$db = Zend_Registry::get('connectDB');
		$mySql = $db->select()
		->from('semester');
		$list = $db->fetchAll($mySql);
		return $list;
	}
	
	/*
	 * lấy ra user đầu tiên
	 */
	
	public function getUserFirts(){
		$db = Zend_Registry::get('connectDB');
		$mySql = $db->select()
					->from('semester')
					->limit(1,0);
		$list = $db->fetchAll($mySql);
		return $list;
	}


}